/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './weixinfenzhangyonghukongzhiqi';
import * as API from './types';

/** 绑定微信小程序openid POST /tourism/client/c/fzuser/bindWxOpenId */
export function useBindWxOpenIdUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultBoolean_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.bindWxOpenIdUsingPost,
    onSuccess(data: API.CommonResultBoolean_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 获取分账用户表详情 GET /tourism/client/c/fzuser/detail */
export function detailUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.detailUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.detailUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['detailUsingGet', options],
  });
}

/** 编辑分账用户表 POST /tourism/client/c/fzuser/edit */
export function useEditUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultString_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.editUsingPost,
    onSuccess(data: API.CommonResultString_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 获取分账用户邀请码 GET /tourism/client/c/fzuser/getInviteCode */
export function getInviteCodeUsingGetQueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.getInviteCodeUsingGETParams;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.getInviteCodeUsingGet(queryKey[1] as typeof options);
    },
    queryKey: ['getInviteCodeUsingGet', options],
  });
}

/** 获取全量分账用户列表 GET /tourism/client/c/fzuser/list */
export function listUsingGet1QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.listUsingGET1Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.listUsingGet1(queryKey[1] as typeof options);
    },
    queryKey: ['listUsingGet1', options],
  });
}

/** 注册分销用户 POST /tourism/client/c/fzuser/register */
export function useRegisterUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultMapStringObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.registerUsingPost,
    onSuccess(data: API.CommonResultMapStringObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 微信小程序登录 POST /tourism/client/c/fzuser/wxLogin */
export function useWxLoginUsingPostMutation(options?: {
  onSuccess?: (value?: API.CommonResultMapStringObject_) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.wxLoginUsingPost,
    onSuccess(data: API.CommonResultMapStringObject_) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}
